<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/7/31
 * Time: 17:54
 */

namespace app\console\middleware;


use think\Controller;
use think\facade\Request;

class Jwt extends Controller
{
    public function handle($request, \Closure $next, $name)
    {
        if(!in_array(Request::module(),['console'])){ //不在这里才验证
            $headers = Request::header();
            $token = Request::header('token');
            $ret = (new \app\third\controller\Jwt())->pub_token($token);
            if($ret !== true){
                return json(['code' => 400, 'message' => '验证失败']);
            }
        }
        return $next($request);
    }
}
